#include <ngx_config.h>
#include <ngx_core.h>
#include <ngx_http.h>
typedef struct ngx_http_cache_control_filter_source_s ngx_http_cache_control_filter_source_t;

typedef enum {
    NGX_HTTP_CACHE_CONTROL_FILTER_MATCH_TYPE_ABSOLUTE = 1,
    NGX_HTTP_CACHE_CONTROL_FILTER_MATCH_TYPE_PREFIX
} ngx_http_cache_control_filter_match_type_t;

typedef struct {
    ngx_int_t (*init_module)(ngx_cycle_t *, ngx_http_cache_control_filter_source_t *);
    ngx_int_t (*init_process)(ngx_cycle_t *, ngx_http_cache_control_filter_source_t *);
    ngx_int_t (*exit_process)(ngx_cycle_t *, ngx_http_cache_control_filter_source_t *);
    ngx_int_t (*get_expire_pair)(ngx_http_request_t *, ngx_http_cache_control_filter_source_t *, time_t *);
} ngx_http_cache_control_filter_methods_t;

struct ngx_http_cache_control_filter_source_s {
    char         *type;
    ngx_str_t    path;
    ngx_uint_t   cache_size; /* in KB format */
    ngx_http_cache_control_filter_match_type_t match_type;
    ngx_http_cache_control_filter_methods_t methods;
    void         *priv_data;
};

#define DEFAULT_CACHE_SIZE 256
#define DEFAULT_MATCH_TYPE NGX_HTTP_CACHE_CONTROL_FILTER_MATCH_TYPE_ABSOLUTE

typedef struct {
    ngx_array_t data_sources; /* array of all data sources */
} ngx_http_cache_control_filter_main_conf_t;


typedef struct {
    ngx_int_t index; /* the index of the data source. if not enabled, -1 */
} ngx_http_cache_control_filter_loc_conf_t;

typedef struct {
    char *type;
    ngx_http_cache_control_filter_methods_t methods;
} ngx_http_cache_control_filter_supported_source_t;

extern ngx_http_cache_control_filter_supported_source_t supported_sources[];
